#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

char* compressString(char* S);

int main()
{
	return 0;
}

char* compressString(char* S)
{
	if (!S[0]) return S;
	char* res = (char*)calloc(100010, sizeof(char));
	res[0] = S[0];

	char ch;
	for (int i = 1, pre = 0, size = 1;; i++) {
		if ((ch = S[i])) {
			if (ch == S[pre])
				continue;
			else {
				/* res[size++] = i - pre + '0'; */
				sprintf(res + size, "%d", i - pre);
				size += log10(i - pre) + 1;
				res[size++] = ch;
				pre = i;
			}
		} else {
			sprintf(res + size, "%d", i - pre);
			size += log10(i - pre) + 1;

			if (i < size) return S;
			break;
		}
	}

	return res;
}
